/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.servicesnpayroll.bl;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import mx.servicesnpayroll.dao.MembresiaFacadeLocal;
import mx.servicesnpayroll.model.Membresia;

/**
 *
 * @author Grnmnd
 */
@Stateless
public class MembresiaBL implements MembresiaBLLocal {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @EJB
    private MembresiaFacadeLocal membresiaFacade;
    
    @Override
    public void create(Membresia em) {
        membresiaFacade.create(em);
    }

    @Override
    public void edit(Membresia em) {
        membresiaFacade.edit(em);
    }

    @Override
    public void remove(Membresia em) {
        em.setEliminada(true);
        membresiaFacade.edit(em);
    }

    @Override
    public List<Membresia> findAll() {
        List<Membresia> all=new ArrayList<Membresia>();
        for(Membresia e:membresiaFacade.findAll()){
            if(!e.getEliminada()){
                all.add(e);
            }
        }
        return all;
    }

    @Override
    public Membresia find(Object id) {
        return membresiaFacade.find(id);
    }

    @Override
    public Membresia find(int id) {
        return membresiaFacade.find(id);
    }
}
